package com.qf.dao.impl;

import com.qf.dao.UserCardDao;
import com.qf.model.Card;
import com.qf.model.Navig;
import com.qf.model.PageBean;
import com.qf.model.pojo.UserCard;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

import java.util.List;

public class UserCardDaoImpl extends BaseDao implements UserCardDao {

    //根据用户id查询是否有审批通过的信用卡
    @Override
    public List<UserCard> findCreditCardByU_id(int u_id) {
        String sql = "select * from card c join user u on c.u_id = u.u_id where c.u_id = ? and c.c_check = 1 and c.c_type = 1";
        List<UserCard> list = queryForList(UserCard.class,sql,u_id);
        return list;
    }
    //查询所有位审核银行卡

    @Override
    public List<UserCard> findAll(PageBean<UserCard> pageBean) {
        String sql1="select * from card c join user u on c.u_id = u.u_id where c.c_check = 0 ";
        List<UserCard> userCards = queryForList(UserCard.class, sql1);
        pageBean.setCount(userCards.size());
        String sql="select * from card c join user u on c.u_id = u.u_id where c.c_check = 0 limit ?,?";
        int i=(pageBean.getCurPage()-1)*pageBean.getPageSize();
        List<UserCard> userCards2 = queryForList(UserCard.class, sql,i,pageBean.getPageSize());
        return userCards2;
    }
}
